// pages/customer_discount/index.js
import {
  request,
} from '../../../utils/requestUtils';
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    total:0,
    page: {
      pageNum: 1,
      pageSize: 5,
    },
    params: {
      keywords: ''
    },
    list: []
  },
    /**
   * 组件的方法列表
   */
  attached:function(){
    this.getList()
  },
  /**
   * 组件的方法列表
   */
  methods: {
    async getList() {
      const result = await request({
        url: `/bus/discount/customer/list?pageNum=${this.data.page.pageNum}&pageSize=${this.data.page.pageSize}`,
        method: "POST",
        data: {}
      })
      if(result.data.code == 200){
        this.setData({
          list: result.data.rows,
          total: result.data.total
        })
      }
    },
    // 领取
    async getInfo(e){
      let info = e.currentTarget.dataset.info
      console.log('e',info)
      const result = await request({
        url: `/bus/cust/customer`,
        method: "POST",
        data: {
          discountId:info.id
        }
      })
      if(result.data.code == 200){
        const modalRes = await wx.showModal({
          showCancel:false,
          content: '领取成功'
        })
        this.getList()
      }
    }
  }
})